package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.LikeTravel;
import cn.wolfcode.trip.base.domain.PrivateMessage;
import cn.wolfcode.trip.base.domain.SystemMessage;
import cn.wolfcode.trip.base.domain.TravelComment;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ILikeMessageService;
import cn.wolfcode.trip.base.service.IPrivateMessageService;
import cn.wolfcode.trip.base.service.ISystemMessageService;
import cn.wolfcode.trip.base.service.ITravelCommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping("allMessages")
public class MessageController {
    @Autowired
    private IPrivateMessageService privateMessageService;
    @Autowired
    private ISystemMessageService  systemMessageService;
    @Autowired
    private ITravelCommentService travelCommentService;
    @Autowired
    private ILikeMessageService    likeMessageService;
    @GetMapping("/{Uid}")
    public Map queryMessageCount(@PathVariable Long Uid, QueryObject qo){
        Map<String,Object> map = new HashMap<>();
        qo.setPageSize(8);
        //私信
        Integer privateMessageCount = privateMessageService.queryPrivateMessageCount(Uid);
        PageInfo<PrivateMessage> privateMessagePageInfo = privateMessageService.query(qo);
        map.put("privateMessageCount",privateMessageCount);
        map.put("privateMessagePageInfo",privateMessagePageInfo);
        //系统消息
        Integer systemMessageCount = systemMessageService.querySystemMessageCount(Uid);
        PageInfo<SystemMessage>  systemMessagePageInfo= systemMessageService.query(qo);
        map.put("systemMessageCount",systemMessageCount);
        map.put("systemMessagePageInfo",systemMessagePageInfo);
        //点赞
        Integer likeCount = likeMessageService.queryLikeCount(Uid);
        PageInfo<LikeTravel>  likePageInfo= likeMessageService.query(qo);
        map.put("likeCount",likeCount);
        map.put("likePageInfo",likePageInfo);
        //评论
        Integer queryCommentCount = travelCommentService.queryCommentCount(Uid);
        PageInfo<TravelComment>  travelCommentPageInfo= travelCommentService.queryAll(qo);
        map.put("queryCommentCount",queryCommentCount);
        map.put("travelCommentPageInfo",travelCommentPageInfo);
        return map;
    }
}
